cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES C CXX)

set(HDF5_COMPONENTS C)
if (HDF5_HL)
    list(APPEND HDF5_COMPONENTS HL)
endif()
if (HDF5_CXX)
    list(APPEND HDF5_COMPONENTS CXX)
endif()
find_package(HDF5 COMPONENTS ${HDF5_COMPONENTS})

add_executable(${PROJECT_NAME} test_package.c)
if(HDF5_CXX)
    target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
endif()

if (TARGET hdf5::hdf5_cpp)
    target_compile_definitions(${PROJECT_NAME} PRIVATE CONAN_HDF5_CXX)
    target_sources(${PROJECT_NAME} PRIVATE test_package.cpp)
    target_link_libraries(${PROJECT_NAME} PRIVATE hdf5::hdf5_cpp)
elseif (HDF5_IS_PARALLEL)
    target_compile_definitions(${PROJECT_NAME} PRIVATE CONAN_HDF5_PARALLEL)
    target_sources(${PROJECT_NAME} PRIVATE test_parallel.c)
    target_link_libraries(${PROJECT_NAME} PRIVATE hdf5::hdf5)
else()
    target_link_libraries(${PROJECT_NAME} PRIVATE hdf5::hdf5)
endif()
